package com.lin.demo.controller;

import com.lin.demo.service.task.AsyncTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author zimingl
 * @Date 2023/4/2 22:42
 * @Description: AsyncController
 */
@Slf4j
@RestController
@RequestMapping("/async")
public class AsyncController {
    @Resource
    private AsyncTask asyncTask;

    @RequestMapping("/task")
    public void task() throws InterruptedException {
        long t1 = System.currentTimeMillis();
        asyncTask.doTask1();
        asyncTask.doTask2();
        Thread.sleep(1000);
        long t2 = System.currentTimeMillis();
        log.info("main方法耗时{} ms", t2-t1);
    }
}
